<template>
    <div>
        <div>新增/修改数据</div>
        <div>
            <table>
                <tbody>
                    <tr>
                        <td>请输入书名：</td>
                        <td><input type="text" v-model="formData.bookName"></td>
                    </tr>
                    <tr>
                        <td>请输入作者名称</td>
                        <td><input type="text" v-model="formData.author"></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td>
                            <input type="button" value="确认保存" @click="btnYes()">
                            <input type="button" value="取消" @click="btnNo()">
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
</template>
<script setup>
import { reactive } from 'vue';
import { useRouter } from 'vue-router';
import { itemAdd } from '@/api/bookapi.js';

let formData = reactive(
{
    bookName:"",
    author:""
})
let router = useRouter()

function btnYes(){
    itemAdd(formData)
    router.push("/book")
    
}
function btnNo(){
    router.push("/book")
}
</script>